package com.isoft.demo01.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.demo01.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


@Mapper
public interface OrderDao extends BaseMapper<Order> {
    @Select("select tb_order.*,tb_user.username,tb_user.phone from tb_order inner join tb_user on tb_order.userid=tb_user.userid " +
            "where tb_order.orderid=#{orderid}")
    public List<Order> find(@Param("orderid")Integer orderid);
//    @Insert("insert into tb_order (id,orderid,userid,ordertime,allprice,status) values(null,#{orderid},#{userid},#{ordertime},(select sum(price) from tb_shop inner join tb_game on tb_shop.gameid=tb_game.gameid where userid=#{userid}),#{status})")
//    int addorder(Order order);
@Select("select tb_order.* " +
        "            from tb_order  " +
        "            where tb_order.id=#{id}")
public Order getDetailById(Integer id);

    @Update("update tb_order set status=#{status}where id=#{id}")
    public int updateDel(@Param("id") Integer id, @Param("status")Integer status);
}
